<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 有一个对象 来判断是否有该属性  对象['属性名']
        let obj = {
            age: 18,
            sex: true
        }
        let temp = 'age';
        if (obj[temp]) {
            console.log('ok');
        } else {
            console.log('no');
        }



        console.log('-----------------------------------------')
        let result = 'abcdefga';
        let info = {};
        for (let i = 0; i < result.length; i++) {
            // 当前字符
            let char = result[i];
            // 对象的属性是否存在
            if (info[char]) {
                // 存在则自加一
                info[char]++

            } else {
                // 不存在则 赋值1
                info[char] = 1;
            }
        }
        console.log(info);

        // 遍历对象的属性和值
        let max = 0;
        let ch = ''
        for (let k in info) {
            console.log(k, info[k]);

            if (info[k] > max) {
                max = info[k];
                ch = k;
            }
        }
        console.log(ch, max);

    </script>
</body>

</html>